import cv2
import matplotlib.pyplot as plt
import numpy as np


def cv2_show(name, img):
    cv2.imshow(name, img)
    cv2.waitKey(0)
    cv2.destroyAllWindows()


if __name__ == "__main__":
    # Default mode of reading image if BGR
    # img_02 = cv2.imread("../images/Camera_A_1.jpg")
    ## Gray image
    # img_02 = cv2.imread("../images/Camera-C_3300.jpg", cv2.IMREAD_GRAYSCALE)
    ## Colored image
    img_02 = cv2.imread("../images/Camera-C_3300.jpg", cv2.IMREAD_COLOR)
    top_size, bottom_size, right_size, left_size = [50, 50, 50, 50]
    replicate = cv2.copyMakeBorder(img_02, top_size, bottom_size, right_size, left_size,
                                   borderType=cv2.BORDER_REPLICATE)
    reflect = cv2.copyMakeBorder(img_02, top_size, bottom_size, right_size, left_size,
                                 cv2.BORDER_REFLECT)
    reflect_101 = cv2.copyMakeBorder(img_02, top_size, bottom_size, right_size, left_size,
                                     cv2.BORDER_REFLECT_101)
    wrap = cv2.copyMakeBorder(img_02, top_size, bottom_size, right_size, left_size,
                              cv2.BORDER_WRAP)
    constant = cv2.copyMakeBorder(img_02, top_size, bottom_size, right_size, left_size,
                                  cv2.BORDER_CONSTANT)
    plt.subplot(231), plt.imshow(img_02, "gray"), plt.title("original")
    plt.subplot(232), plt.imshow(replicate, "gray"), plt.title("replicate")
    plt.subplot(233), plt.imshow(reflect, "gray"), plt.title("reflect")
    plt.subplot(234), plt.imshow(reflect_101, "gray"), plt.title("reflect_101")
    plt.subplot(235), plt.imshow(wrap, "gray"), plt.title("wrap")
    plt.subplot(236), plt.imshow(constant, "gray"), plt.title("constant")
    plt.show()
